
import { defineStore } from 'pinia'
import { requestAuthor, requestAuthorAndPoetryById } from './find.api'

export default defineStore('find', {
    state: () => {
        return {
            
        }
    },
    getters: {
    },
    actions: {
        // 获取作者信息
        getAuthor() {
            return new Promise((resolve, reject) => {
                requestAuthor().then(response => {
                    const res: any = response.data
                    if (res.code === 200) {
                        resolve(res.data)
                    }
                })
            })
        },
        // 根据id获取作者及作品信息
        getAuthorAndPoetryById(data: any) {
            return new Promise((resolve, reject) => {
                requestAuthorAndPoetryById(data).then(response => {
                    const res: any = response.data
                    if (res.code === 200) {
                        resolve(res.data)
                    }
                })
            })
        },
    }
})
